/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Eduardo
 */
@Entity
@Table(name = "Detalle_Orden")
@NamedQueries({
    @NamedQuery(name = "DetalleOrden.findAll", query = "SELECT d FROM DetalleOrden d"),
    @NamedQuery(name = "DetalleOrden.findByIdDetalleOrden", query = "SELECT d FROM DetalleOrden d WHERE d.idDetalleOrden = :idDetalleOrden"),
    @NamedQuery(name = "DetalleOrden.findByCantidad", query = "SELECT d FROM DetalleOrden d WHERE d.cantidad = :cantidad"),
    @NamedQuery(name = "DetalleOrden.findByPu", query = "SELECT d FROM DetalleOrden d WHERE d.pu = :pu"),
    @NamedQuery(name = "DetalleOrden.findByTotal", query = "SELECT d FROM DetalleOrden d WHERE d.total = :total")})
public class DetalleOrden implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IdDetalleOrden")
    private Integer idDetalleOrden;
    @Column(name = "Cantidad")
    private Integer cantidad;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PU")
    private Double pu;
    @Column(name = "Total")
    private Double total;
    @JoinColumn(name = "NumOrdCompra", referencedColumnName = "NumeroOrdenCompra")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private OrdenCompra numOrdCompra;
    @JoinColumn(name = "IdPublicacion", referencedColumnName = "IdPublicacion")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Publicacion idPublicacion;

    public DetalleOrden() {
    }

    public DetalleOrden(Integer idDetalleOrden) {
        this.idDetalleOrden = idDetalleOrden;
    }

    public Integer getIdDetalleOrden() {
        return idDetalleOrden;
    }

    public void setIdDetalleOrden(Integer idDetalleOrden) {
        this.idDetalleOrden = idDetalleOrden;
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        this.cantidad = cantidad;
    }

    public Double getPu() {
        return pu;
    }

    public void setPu(Double pu) {
        this.pu = pu;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    public OrdenCompra getNumOrdCompra() {
        return numOrdCompra;
    }

    public void setNumOrdCompra(OrdenCompra numOrdCompra) {
        this.numOrdCompra = numOrdCompra;
    }

    public Publicacion getIdPublicacion() {
        return idPublicacion;
    }

    public void setIdPublicacion(Publicacion idPublicacion) {
        this.idPublicacion = idPublicacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetalleOrden != null ? idDetalleOrden.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleOrden)) {
            return false;
        }
        DetalleOrden other = (DetalleOrden) object;
        if ((this.idDetalleOrden == null && other.idDetalleOrden != null) || (this.idDetalleOrden != null && !this.idDetalleOrden.equals(other.idDetalleOrden))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.DetalleOrden[ idDetalleOrden=" + idDetalleOrden + " ]";
    }
    
}
